package com.ruoyi.mdkt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.mdkt.entity.Discuss;
import com.ruoyi.mdkt.entity.vo.DiscussVO;
import com.ruoyi.mdkt.mapper.DiscussMapper;
import com.ruoyi.mdkt.service.DiscussService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author gwl
 * @since 2022-10-22
 */
@Service
public class DiscussServiceImpl extends ServiceImpl<DiscussMapper, Discuss> implements DiscussService {

    @Autowired
    private DiscussMapper discussMapper;
    @Override
    public List<DiscussVO> getDiscussByLeaderId(String leaderId) {
        return discussMapper.getDiscussByLeaderId(leaderId);
    }

    @Override
    public List<DiscussVO> getDiscussByParentId(String parentId) {
        return discussMapper.getDiscussByParentId(parentId);
    }

    @Override
    public Discuss getDiscussByDiscussId(String discussId) {
        LambdaQueryWrapper<Discuss> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Discuss::getId,discussId);
        Discuss discuss = discussMapper.selectOne(lambdaQueryWrapper);
        return discuss;
    }
}
